Add debug info to UnresolvedTypeError #5432
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is for debugging
UnresolvedTypeErrors that come up sporadically in production. After digging through the code, I still don't know why this would happen.Basically, this check is returning an empty array:
graphql-ruby/lib/graphql/schema/visibility/profile.rb
Lines 404 to 413 in 321e91e
So, I added a debug message for each part of that check. For background, the different values included here are:
Visibility#all_interface_type_memberships:{ InterfaceType => { ObjectType => [TypeMembership, ...] } }. This map of types and memberhsips is totally unfiltered; it contains everything that the top-levelSchema::Visibilityinstance has discovered in the schema. By the time it is referenced, theVisibilityinstance has performedensure_all_loaded(because the only way to be sure you have them all is to traverse the whole schema), so it should never return a partial result.Visibility::Profile#referenced?(impl_type): This checks to make sure thatimpl_typehas some visible reference inside the schema. (For Object types, references would beGraphQL::Schema::Fieldinstances.) For a type included via.orphan_types(...), I would expect references to be populated by this code, such that all reference to the interface are propagated to the object that implements the interface:graphql-ruby/lib/graphql/schema/visibility.rb
Lines 293 to 300 in 321e91e
@cached_visible[impl_type]checks that the type's.visible?(context)method returnstruememberships.map { |itm| @cached_visible[itm] }checks that the TypeMembership object (which links the object type to the interface) also returnstrue. (You can implement#visible?on them to hide interface implementations while still publishing the interface type and the object type.)This can be monkey-patched into the application like this: